// 带参数路由
<template>
  <div>
    <ul>
        <li v-for="m in messagelist" :key="m.id">
            <!-- <a href="">{{m.title}}</a> -->

            <!-- 路由跳转 带参数 to的字符串写法  -->
            <!-- <router-link :to="`/home/message/datle?id=${m.id}&title=${m.title}`">{{m.title}}</router-link> -->

            <!-- 路由跳转 带参数 to的对象写法  path路由路径 query所传参数-->
            <router-link :to="{path:'/home/message/datle',query:{id:m.id,title:m.title}}">
                {{m.title}}
            </router-link>
            <button @click="pushShow(m)">push查看</button>
            <button @click="replaceShow(m)">replace查看</button>
        </li>
    </ul>
    <hr>

     <router-view></router-view>
    
  </div>
  
</template>

<script>
export default {
    name:'Message',
    data() {
        return {
            messagelist:[
                {id:'001',title:'消息01'},
                {id:'002',title:'消息02'},
                {id:'003',title:'消息03'}
            ]
        }
    },
    methods:{
        pushShow(m){
            // 利用this.$router身上的push来实现编码路由跳转，
            this.$router.push({
                name:'xiangqing',
                query:{id:m.id,title:m.title}
            })
        },
        replaceShow(m){
            // 利用this.$router身上的push来实现编码路由跳转，
            this.$router.replace({
                name:'xiangqing',
                query:{id:m.id,title:m.title}
            })
        }
    }
}
</script>

<style>

</style>